#include <bits/stdc++.h>
#define LL __int128
using namespace std;
const LL mod = 998244353;
inline LL read(){
    LL x=0,f=1;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        if(ch=='-')
            f=-1;
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=x*10+ch-'0';
        ch=getchar();
    }
    return x*f;
}

inline void print(LL x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    if(x>9)
        print(x/10);
    putchar(x%10+'0');
}

int main() {
	LL n, m;
	n = read(), m = read();
	LL inv2 = (mod-mod/2)%mod;
	int q;
	scanf("%d", &q);
	while(q -- ) {
		LL x1, x2, y1, y2;
		x1 = read(), x2 = read(), y1 = read(), y2 = read();
		LL val1 = 0, val2 = 0;
		LL len1 = (y2-y1+1 + 1) / 2;
		LL len2 = (y2-y1+1) / 2;
		LL l1 = (x2-x1+1 + 1) / 2;
		LL l2 = (x2-x1+1) / 2;
		LL sum1 = 0, sum2 = 0;
		if((x1+y1) % 2 == 0) {
			LL a1 = ((x1-1+mod)*m%mod+y1+mod) % mod;
			LL an = (a1+(len1-1+mod)*2%mod+mod) % mod;
			val1 = (a1 + an)*len1%mod*inv2%mod;
			if(len2 > 0 && l2 > 0) {
				LL b1 = (x1*m+y1+1) % mod;
				LL bn = (b1+(len2-1+mod)*2%mod+mod) % mod;
				val2 = (b1 + bn)*len2%mod*inv2%mod;
			}
			sum1 = val1, sum2 = val2;
			l1 --, l2 --;
			if(l1 > 0 && len1 > 0) {
				sum1 = (sum1 + l1*val1%mod + len1*(m*l1+m*l1%mod*l1%mod)%mod) % mod;
			}
			if(l2 > 0 && len2 > 0) {
				sum2 = (sum2 + l2*val2%mod + len2*(m*l2+m*l2%mod*l2%mod)%mod) % mod;
			}
		}
		else {
			LL a1 = (x1*m+y1) % mod;
			LL an = (a1+(len1-1+mod)*2%mod+mod) % mod;
			if(l2 > 0)
			val2 = (a1 + an)*len1%mod*inv2%mod;
			if(len2 > 0) {
				LL b1 = ((x1-1)*m+y1+1+mod) % mod;
				LL bn = (b1+(len2-1+mod)*2%mod+mod) % mod;
				val1 = (b1 + bn)*len2%mod*inv2%mod;
			}
			sum1 = val1, sum2 = val2;
			l1 --, l2 --;
			if(l1 > 0 && len2 > 0) {
				sum1 = (sum1 + l1*val1%mod + len2*(m*l1+m*l1%mod*l1%mod)%mod) % mod;
			}
			if(l2 > 0 && len1 > 0) {
				sum2 = (sum2 + l2*val2%mod + len1*(m*l2+m*l2%mod*l2%mod)%mod) % mod;
			}
		}
		LL ans = (sum1 + sum2) % mod;
		print(ans);
		printf("\n");
	}
	return 0;
}